package cn.com.xjnt.vas.ordering.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.frameworks.core.repository.BaseRepository;
import com.frameworks.core.service.AbstractBaseService;

import cn.com.xjnt.vas.ordering.domain.entity.Hospital;
import cn.com.xjnt.vas.ordering.domain.entity.Notice;
import cn.com.xjnt.vas.ordering.repository.NoticeRepository;
import cn.com.xjnt.vas.ordering.service.NoticeService;

/** 
* 类说明：
* @author 作者 LUXIN
* @version 创建时间：2016年5月11日17:49:03
*/
@Service
@Transactional
public class NoticeServiceImpl extends AbstractBaseService<Notice, Long> implements NoticeService {
    @Autowired
    private NoticeRepository noticeRepository;
    
    @Override
    protected BaseRepository<Notice, Long> getBaseRepository() {
        return noticeRepository;
    }

    @Override
    public void save(Notice entity) {
        super.saveOrUpdate(entity);
    }

    @Override
    public void update(Notice entity) {
        super.saveOrUpdate(entity);
    }

    @Override
    public void examineById(Long id) {
       Notice notice = noticeRepository.findOne(id); 
       notice.setStatus(1);
       super.saveOrUpdate(notice);
    }

    @Override
    public void examineByIds(Long[] ids) {
        for (Long id : ids) {
            Notice notice = noticeRepository.findOne(id); 
            notice.setStatus(1);
            super.saveOrUpdate(notice);
        }
    }

    @Override
    public void disableById(Long id) {
        Notice notice = noticeRepository.findOne(id); 
        notice.setStatus(2);
        super.saveOrUpdate(notice); 
    }

    @Override
    public void disableByIds(Long[] ids) {
        for (Long id : ids) {
            Notice notice = noticeRepository.findOne(id); 
            notice.setStatus(2);
            super.saveOrUpdate(notice);
        }
    }

    @Override
    public List<Notice> findByHospital(Hospital hospital) {
        return noticeRepository.findByHospital(hospital);
    }
}
 